﻿using Microsoft.AspNetCore.Mvc;
using System.Globalization;

namespace Controllers
{
    public class ApiModel
    {
        //业务状态 可以是 0.成功 2.失败等等
        public int status { get; set; }
        //业务数据
        public object data { get; set; }
        //提示信息
        public string msg { get; set; }
    }
    public enum Status
    {
        Success=0,
        Error,
    }
    public class BaseController: ControllerBase
    {
        
        protected ApiModel apiModel(Status status,string msg="",object data=null)
        {
            return new ApiModel()
            {
                status = (int)status,
                data = data,
                msg = msg
            };
           
        }
        /// <summary>
        /// "2016/10/10"转日期
        /// </summary>
        public DateTime ConvertDatetime(string datetimestr)
        {
            DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
            dtFormat.ShortDatePattern = "yyyy-MM-dd";
            DateTime dt = Convert.ToDateTime(datetimestr, dtFormat);
            return dt;
        }
    }
}
